import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            imports:["vue","vue-router"],
            resolvers: [ElementPlusResolver()]
        }),
        Components({
            resolvers: [ElementPlusResolver()]
        })
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    server:{
        port:"7777",
        // 代理服务器
        proxy:{
            "/qilin":{
				target:"http://localhost:5000/",
				changeOrigin:true, //允许跨域
                ws:false, //允许websocket代理
                rewrite:(path)=>path.replace(/^\/qilin/,"")
			},
            "/ws":{
                target:"ws://192.168.10.103:8081",
                ws:true,
                changeOrigin:true,
                rewrite:(path)=>path
            }
        }
    },
    css:{
        devSourcemap:true, //开发模式下开启css样式sourceMap
        preprocessorOptions:{
            scss:{
                additionalData:"@import '@/assets/scss/common.scss';"
            }
        }
    }
});
